﻿using System;
using Castle.MicroKernel;
using MetaContainer;
using MetaContainer.Autofac;
using MetaContainer.Castle;
using MetaContainer.Unity;
using Microsoft.Practices.Unity;
using Samples.MetaContainer.MoneyExchangeSample.ContainerAbstraction;
using Samples.MetaContainer.MoneyExchangeSample.DomainModel;
using Samples.MetaContainer.MoneyExchangeSample.DomainModel.Services;

namespace Samples.MetaContainer.MoneyExchangeSample.ConsoleHost
{
    class Program
    {
        static void Main()
        {
            InitContainer();
            Order order = new Order("EUR", 10);
            Console.WriteLine("Order - after exchange: {0}", order.GetValue());
            Console.ReadKey();
        }

        private static void InitContainer()
        {
            IMetaContainer container = GetMetaContainer();
            container.Register<IMoneyExchange, MoneyExchange>();
            ContextContainer.SetMetaContainerProvider(() => container);
        }

        private static IMetaContainer GetMetaContainer()
        {
            //return new UnityMetaContainerAdapter(new UnityContainer());
            //return new CastleKernelMetaContainerAdapter(new DefaultKernel());
            return new AutofacMetaContainerAdapter();
        }
    }
}
